package com.taxshare.seller.controller;

import com.taxshare.mybatis.pager.PageRequest;
import com.taxshare.pvalidate.ParamValid;
import com.taxshare.response.beans.Response;
import com.taxshare.seller.service.GoodsManageService;
import com.taxshare.seller.view.dto.GoodsManageDTO;
import com.taxshare.seller.view.dto.PjspbmDTO;
import com.taxshare.seller.view.dto.TaxComplilationDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * @author YANG
 * @date 2021/3/16
 */
@RestController
@RequestMapping("/goodsManage")
@Api(tags = "商管商品管理")
public class GoodsManageController {

    @Autowired
    GoodsManageService goodsManageService;

    @PostMapping("/add")
    @ApiOperation(value = "商品管理新增", notes = "商品管理")
    @ParamValid
    public Response goodsManageAdd(@RequestBody @Valid GoodsManageDTO goodsManageDto) {
        return goodsManageService.goodsManageAdd(goodsManageDto);
    }

    @PostMapping("/remove")
    @ApiOperation(value = "商品管理删除", notes = "商品管理")
    public Response goodsManageRemove(@RequestBody List<String> ids) {
        return goodsManageService.goodsManageRemove(ids);
    }

    @PostMapping("/edit")
    @ApiOperation(value = "商品管理编辑", notes = "商品管理")
    public Response goodsManageEdit(@RequestBody GoodsManageDTO goodsManageDto) {
        return goodsManageService.goodsManageEdit(goodsManageDto);
    }

    @PostMapping("/query")
    @ApiOperation(value = "商品管理查询", notes = "商品管理")
    public Response goodsManageQuery(@RequestBody PageRequest<TaxComplilationDTO> query) {
        return goodsManageService.goodsManageQuery(query);
    }

    @PostMapping("/getProductCode")
    @ApiOperation(value = "获取商品编码树形", notes = "获取商品编码树形")
    public Response getProductCode(@RequestBody PjspbmDTO pjspbmDTO){
        return goodsManageService.getProductCode(pjspbmDTO);
    }

    @PostMapping("/importGoodsManage")
    @ApiOperation(value = "商品管理导入", notes = "地产商品管理")
    public Response goodsManageImport(@RequestParam("file") MultipartFile multipartFile){
        return goodsManageService.GoodsManageImport(multipartFile);
    }

    @GetMapping("/exportGoodsManage")
    @ApiOperation(value = "商品管理商管导出", notes = "商品管理")
    public void exportGoodsManage(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse) throws Exception{
        goodsManageService.exportGoodsManageExport(httpServletRequest,httpServletResponse);
    }

    @PostMapping("/queryAll")
    @ApiOperation(value = "商品管理查询全部", notes = "商品管理全部")
    public Response goodsManageQuery(@RequestBody TaxComplilationDTO query) {
        return goodsManageService.getGoods(query);
    }

    @PostMapping("/queryAllPost")
    @ApiOperation(value = "商品管理查询全部Post", notes = "商品管理全部")
    public Response queryAllPost(@RequestBody TaxComplilationDTO query) {
        return goodsManageService.queryAllPost(query);
    }
}
